package com.zephyr.vchcenter.bpm.action;

import org.apache.log4j.Logger;

import com.hiaward.bpm.action.TaskAction;
import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.ServiceException;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.dao.IBaseDao;
import com.zephyr.vchcenter.helper.SpringHelper;

public class FinancialAuditAction extends TaskAction {
	private final Logger log=Logger.getLogger(FinancialAuditAction.class);
	@Override
	public void perform(ServiceContext arg0) throws ServiceException,
			ParameterException {
		log.debug("进入FinancialAuditAction..........");
		 String accno=(String)arg0.getInputParameterValue("accno");
         String amount=(String)arg0.getInputParameterValue("amount");
         String vchno=(String)arg0.getInputParameterValue("vchno");
         String vchtype=(String)arg0.getInputParameterValue("vchtype");
         String vchdate=(String)arg0.getInputParameterValue("vchdate");
         String vchsid=(String)arg0.getInputParameterValue("vchsid");
         String acctype=(String)arg0.getInputParameterValue("acctype");
         log.debug("帐户类型"+acctype);
         String rtreason=(String)arg0.getInputParameterValue("rtreason");
         log.debug("退票理由"+rtreason);
         String vchpwd=(String)arg0.getInputParameterValue("vchpwd");
         String batno=(String)arg0.getInputParameterValue("batno");
         String auditResult=(String)arg0.getInputParameterValue("chkres");
         String verifyState=(String)arg0.getInputParameterValue("chkstate");
         log.debug("审票结果"+auditResult);
         log.debug("审票状态"+verifyState);
         IBaseDao dao=(IBaseDao)SpringHelper.getBean("baseDao");
         Voucher voucher=(Voucher)dao.findById("Voucher",vchsid);
         if("2".equals(acctype)){
        	 log.debug("财政胡部分提交");
        	 String finaid=(String)arg0.getInputParameterValue("finaid");
        	 String signtype=(String)arg0.getInputParameterValue("signtype");
        	 String paymode=(String)arg0.getInputParameterValue("paymode");
        	 String ifamount=(String)arg0.getInputParameterValue("ifamount");
        	 String payinst=(String)arg0.getInputParameterValue("payinst");
        	 String payvchno=(String)arg0.getInputParameterValue("payvchno");
        	 String vchchar=(String)arg0.getInputParameterValue("vchchar");
        	 String payamount=(String)arg0.getInputParameterValue("payamount");
        	 voucher.setFinaid(finaid);
        	 voucher.setSigntype(signtype);
        	 voucher.setPaymode(paymode);
        	 voucher.setIfamount(ifamount);
        	 voucher.setPayinst(payinst);
        	 voucher.setPayvchno(payvchno);
        	 voucher.setVchchar(vchchar);
        	 voucher.setPayamount(payamount);
         }
         voucher.setAcctype(acctype);
         voucher.setRtreason(rtreason);
         voucher.setAccno(accno);
         voucher.setAmount(amount);
         voucher.setVchno(vchno);
         voucher.setVchdate(vchdate);
         voucher.setVchpwd(vchpwd);
         voucher.setBatno(batno);
         voucher.setPswdres("1");
         voucher.setChkclkno("黄兵");
         voucher.setVchtype(vchtype);
         voucher.setAcctype(acctype);
         voucher.setChkres(auditResult);
         voucher.setChkstate(verifyState);
         dao.saveOrUpdate(voucher);
		log.debug("离开FinancialAuditAction..........");
	}

	@Override
	public void serviceExceptionHandle(ServiceContext arg0,
			ServiceException arg1) {
		

	}

}
